asm
  ld sp,$DFFF
  end asm

#include "./library/smsrnd.bas"
#include "./library/smsdelay.bas"

dim eee as uinteger at $C010
dim seed as uinteger at $C012
dim ee0 as uinteger at $C014
dim ee1 as uinteger at $C016
dim ee2 as uinteger at $C018
dim ee3 as uinteger at $C01A
dim eex as uinteger at $C01C
dim eey as uinteger at $C01E

seed=0

sub homerunpalette(tid1 as uinteger,tvl1 as ubyte):
  poke $B000+tid1,tvl1
  end sub

sub homerunpalettergb(tid1 as uinteger,tvl1 as uinteger):
  poke $B000+tid1, ( ((tvl1 band %111000000000)/512) bor ((tvl1 band %11100000)/4) ) bor ((tvl1 band %1100)*16)
  end sub

sub homerunputchar(txp1 as uinteger,typ1 as uinteger,tch1 as ubyte,tat1 as ubyte):
  poke $8000+typ1*64+txp1,tch1
  poke $9000+typ1*64+txp1,tat1
  end sub



for ee0=$00 to $3F 'colorram
  seed=smsrnd(seed)
  homerunpalettergb(ee0,seed)
  next

for ee0=0 to 29
  for ee1=0 to 31
    seed=smsrnd(seed):ee2=seed
    seed=smsrnd(seed)
    homerunputchar(ee1,ee0,seed band 3,ee2 band $0F)
    smsdelay(500)
    next:next

for ee0=0 to 15
  for ee1=0 to 15
    homerunputchar(ee1+15,ee0+13,ee0*16+ee1,1)
    smsdelay(5000)
    next:next


eee=0:eex=8:eey=8
do

homerunputchar(1,1,48+(int(eee/100) mod 10),1)
homerunputchar(2,1,48+(int(eee/10) mod 10),1)
homerunputchar(3,1,48+(eee mod 10),1)

ee0=in($40)
homerunputchar(1,3,48+(int(ee0/100) mod 10),1)
homerunputchar(2,3,48+(int(ee0/10) mod 10),1)
homerunputchar(3,3,48+(ee0 mod 10),1)

ee0=in($50)
homerunputchar(1,4,48+(int(ee0/100) mod 10),1)
homerunputchar(2,4,48+(int(ee0/10) mod 10),1)
homerunputchar(3,4,48+(ee0 mod 10),1)

ee0=in($60)
homerunputchar(1,5,48+(int(ee0/100) mod 10),1)
homerunputchar(2,5,48+(int(ee0/10) mod 10),1)
homerunputchar(3,5,48+(ee0 mod 10),1)

eex=eex+((ee0 band 4)/4)-((ee0 band 8)/8)
eey=eey-((ee0 band 1)/1)+((ee0 band 2)/2)

homerunputchar(eex,eey,eee mod 106 ,1)

eee=eee+1:smsdelay(5000)
loop

do:loop

'-------------------------------


do

for ee2=$B000 to $B03F 'colorram
  seed=smsrnd(seed)
  poke ee2,seed
  smsdelay(100)
  next

''---------- bbgggrrr  
'poke $B000,%00000001
'poke $B001,%00000010
'poke $B002,%00000100
'poke $B003,%00001000
'poke $B004,%00010000
'poke $B005,%00100000
'poke $B006,%01000000
'poke $B007,%10000000
'homerunpalettergb(16,$F00)
'homerunpalettergb(17,$0F0)
'homerunpalettergb(18,$00F)


smsdelay(50000)
smsdelay(50000)

for ee2=$9000 to $9FFF 'videoram2-attr
  seed=smsrnd(seed)
  poke ee2,seed
  smsdelay(100)
  next

for ee2=$8000 to $8FFF 'videoram1-chr
  seed=smsrnd(seed)
  poke ee2,seed
  smsdelay(100)
  next

loop
do

for ee2=$A000 to $A0FF 'spriteram
  seed=smsrnd(seed)
  poke ee2,seed
  smsdelay(100)
  next

loop

do:loop


'static ADDRESS_MAP_START( homerun_memmap, AS_PROGRAM, 8, homerun_state )
'	AM_RANGE(0x0000, 0x3fff) AM_ROM
'	AM_RANGE(0x4000, 0x7fff) AM_ROMBANK("bank1")
'	AM_RANGE(0x8000, 0x9fff) AM_RAM_WRITE(homerun_videoram_w) AM_SHARE("videoram")
'	AM_RANGE(0xa000, 0xa0ff) AM_RAM AM_SHARE("spriteram")
'	AM_RANGE(0xb000, 0xb03f) AM_RAM_WRITE(homerun_color_w) AM_SHARE("colorram")
'	AM_RANGE(0xc000, 0xdfff) AM_RAM
'ADDRESS_MAP_END

'static ADDRESS_MAP_START( homerun_iomap, AS_IO, 8, homerun_state )
'	ADDRESS_MAP_GLOBAL_MASK(0xff)
'	AM_RANGE(0x10, 0x10) AM_WRITE(homerun_d7756_sample_w)
'	AM_RANGE(0x20, 0x20) AM_WRITE(homerun_control_w)
'	AM_RANGE(0x30, 0x33) AM_DEVREADWRITE("ppi8255", i8255_device, read, write)
'	AM_RANGE(0x40, 0x40) AM_READ_PORT("IN0")
'	AM_RANGE(0x50, 0x50) AM_READ_PORT("IN2")
'	AM_RANGE(0x60, 0x60) AM_READ_PORT("IN1")
'	AM_RANGE(0x70, 0x71) AM_DEVREADWRITE("ymsnd", ym2203_device, read, write)
'ADDRESS_MAP_END

